home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 65.zip
/
BS1 part 65
/
Math Visin v2.1 disk 1.adf
/
Arexx.WB
/
Animation
/
MakeZoom
< prev
next >
Wrap
Text File
|
1992-02-12
|
18KB
|
544 lines
/* MakeZoom Do-all, Be-all Interactive Animation Maker 24-Apr-90 dh
This program attempts to automate the production of animations using
MathVision. You can have the coordinates change over time for a 'zooming'
effect, and/or change the variable (p). Each frame is saved to disk after
it is computed, and a script file may be written, to aid you in combining
the files into an animation. Pictures are spread across multiple disks
as there is room, and the production process may be halted and restarted
at will.
========================== DESCRIPTIONS OF COMMANDS ======================
V - Vary You may choose to have the coordinates and/or the variable
P change from frame to frame. If you choose to vary the
coordinates, you should also set the starting and ending
coordinates (C). If you choose to vary the parameter, you
should also set the starting and ending values for the
parameter (P). If the coordinates or parameter are not
being varied, they are ignored, and need not be set.
C - Coords The starting and ending coordinates may be changed. You may
either enter them directly, or have the values copied from
MathVision. Feel free to flip back to MathVision and load
a picture to get coordinates to copy. It is assumed that
you are zooming in, that is, toward 'smaller' coordinates.
P - Parameter The variable 'P' is varied from the starting to ending
values linearly, divided into Frames steps. You should
use the variable 'P' in your function, as in
Mandel(x,y,x,y,100,P).
D - Filename The filename tells where the plotted pictures should be
stored. If you have a hard disk which can contain all
the pictures generated, enter something like
DH0:DRAWER/Pic. If you are storing on diskettes, enter
something like ZOOM:Pic, so everything is in the root
directory. If the disk is filled up, this program will
tack a number onto the volume name, starting with 1, and
attempt to write to that, ie. ZOOM1:Pic. It is good to
have a number of disks formatted and ready to go, with names
such as Zoom, Zoom1, Zoom2, Zoom3...
I - Instruction Normally, this will be 'Plot'. If you want to execute
a different type of plot, such as DivideAndConquer (in the
Mandelbrot hook), enter that command here. More than
one command may be put here, separated by semicolons, but
only the first is retrieved from the Settings file.
This string is interpreted by ARexx, so make these valid
ARexx commands/instructions.
F - Frames This specifies the number of pictures to be plotted, and
is also used to determine the amount of change between
frames. Larger numbers give longer, smoother animations.
N - Next Frame This is the number of the next picture to be plotted.
If the production was interrupted (power interruption)
such that the settings were not saved, you may need to
set this manually. Normally, leave it alone.
G - Go! Proceed with production, using all the parameters above.
You may stop production by clicking on a MathVision screen,
and pressing <Ctrl><Esc>. Remember to use <Esc> too if you
want the plotting to stop immediately.
L - Load Settings Load settings from file. This is useful for resuming
production after having used your Amiga for other
purposes (ie, Real Work.)
S - Save Settings Save settings to file. It is a good idea to save your
settings before you actually begin production, and each
time you interrupt production and quit this program.
W - Write Script This creates a file containing the names of all pictures
plotted. The program MakeAnim requires a script of this
type.
============================== EXAMPLE OF USE ==============================
Suppose I wanted to do a zoom of the Mandelbrot set, using 100 frames.
- Format 2 diskettes, with the names MZoom and MZoom1
- Start MathVision running
- Turn off Write Icons in the Project/Save menu. (saves space)
- Load the Mandelbrot hook for MathVision
- Start this program running
- Set the coordinates. I set the starting coordinates myself, since I
want to start with the full Mandelbrot set. I load my 'target'
picture (the one I want the zoom to end with) into MathVision, and
get the ending coordinates from MathVision.
- Make sure MathVision is set up with the right formula, scaling, colors, etc.
- Set the filename. I'll do this on floppies, with the name MZoom:M
- Set the instruction. I want to do a DivideAndConquer plot, so I put
that here.
- Frames I set at 100.
- Save Settings, on the MZoom disk, for future reference.
- Insert the MZoom and MZoom1 disks in my drives.
- hit Go
- go to bed
Suppose that when I awoke, it had only finished through frame 69, and
I needed to use my computer for other things during the day.
- Click on a MathVision screen
- Press <Ctrl><Esc> and then <ESC> (stop production)
- Save settings and exit program
Later, I wanted to continue production.
- Start MathVision running
- Turn off Write Icons in the Project/Save menu. (saves space)
- Load the Mandelbrot hook for MathVision
- Load the initial picture (MZoom:M0000, in this case)
- Start this program
- Load settings
- Go
This time, the production finished.
- Save Settings (one never knows!)
- Write Script file
- exit this program
- quit MathVision
- Edit the script file, to allow for loops, special effects, etc.
- Make the animation, using a program such as the PD makeanim.
============================================================================ */
ADDRESS "MathVision"
OPTIONS RESULTS
OPTIONS FAILAT 10
NUMERIC DIGITS 14
SIGNAL ON ERROR
Xmin0 = 0; XMax0 = 1
Ymin0 = 0; YMax0 = 1
Xmin1 = 0; XMax1 = 1
Ymin1 = 0; YMax1 = 1
VaryCoords = 1; VaryParameter = 0
ParameterStart = 0; ParameterEnd = 1
Frames = 10; NextFrame = 0
Volume = "Zoom"; Path = "Pic"; Filename = Volume":"Path
DiskNumber = 0
ArchiveFile = "Zoom:ZoomSettings"
Instruction = "Plot"
ElapsedTime = 0
Complete = 0
DiskMargin = 45 /* panic when only this many K space left */
ClrScr = D2C(12)
StopSign "F"
QuitZoom = 0
DO WHILE (QuitZoom==0)
command = MENU()
SELECT
WHEN command = 'F' THEN Frames = GetAns("Frames", Frames )
WHEN command = 'L' THEN CALL LoadSettings
WHEN command = 'S' THEN CALL SaveSettings
WHEN command = 'W' THEN CALL WriteScript
WHEN command = 'G' THEN CALL Zoom
WHEN command = 'N' THEN
DO
NextFrame = GetAns("Next Frame",NextFrame)
if (NextFrame==0) THEN
DO
ElapsedTime = 0
Complete = 0
END
END
WHEN command = 'I' THEN
DO
Say "Enter Plotting instructions on the line below:"
OPTIONS PROMPT ""
PARSE PULL I
if (Length(i)~=0)
THEN Instruction = i
END
WHEN command = 'X' THEN
DO
QuitZoom = GetBoo("Do you really want to exit?",QuitZoom)
if (QuitZoom~=0) THEN
DO
ans = GetBoo("Save Settings before exit?", 1)
if (ans~=0) THEN CALL SaveSettings
END
END
WHEN command = 'V' THEN
DO
VaryCoords = GetBoo("Vary Coordinates", VaryCoords)
VaryParameter = GetBoo("Vary Parameter", VaryParameter)
END
WHEN command = 'P' THEN
DO
ParameterStart = GetAns("Starting Parameter", ParameterStart )
ParameterEnd = GetAns("Ending Parameter", ParameterEnd )
END
WHEN command = 'C' THEN
DO
if (GetBoo("Change Starting Coordinates", 0)~=0) THEN
DO
if (GetBoo("Get Coordinates from MathVision",0)~=0) THEN
DO
Get XMin; Xmin0 = RESULT
Get XMax; XMax0 = RESULT
Get YMin; Ymin0 = RESULT
Get YMax; YMax0 = RESULT
END
ELSE
DO
XMin0 = GetAns("XMin",XMin0)
XMax0 = GetAns("XMax",XMax0)
YMin0 = GetAns("YMin",YMin0)
YMax0 = GetAns("YMax",YMax0)
END
END
if (GetBoo("Change Ending Coordinates", 0)~=0) THEN
DO
if (GetBoo("Get Coordinates from MathVision",0)~=0) THEN
DO
Get XMin; Xmin1 = RESULT
Get XMax; XMax1 = RESULT
Get YMin; Ymin1 = RESULT
Get YMax; YMax1 = RESULT
END
ELSE
DO
XMin1 = GetAns("XMin",XMin1)
XMax1 = GetAns("XMax",XMax1)
YMin1 = GetAns("YMin",YMin1)
YMax1 = GetAns("YMax",YMax1)
END
END
END
WHEN command = 'D' THEN
DO FOREVER
Filename = GetAns("Filename", FileName )
i = index(filename,":")
if (i~=0)
THEN
DO Volume = Left(filename,i-1)
Path = SubStr(filename,i+1)
BREAK
END
ELSE
ans = SayError("Please specify a volume and path, ie ZOOM:Pic")
if (i~=0) THEN BREAK
END
OTHERWISE;
END /*select*/
END
EXIT
/*================================== MENU ================================= */
MENU:
SAY ClrScr "---------------- MakeZoom Menu -----------------"
SAY
SAY "V - Vary: Coordinates ("Boo2Text(VaryCoords)")"
SAY " Parameter ("Boo2Text(VaryParameter)")"
if (VaryCoords~=0)
THEN
DO
SAY "C - Coords Start: Xmin " XMin0 " Xmax " XMax0
SAY " Ymin " YMin0 " Ymax " YMax0
SAY " End: Xmin " XMin1 " Xmax " XMax1
SAY " Ymin " YMin1 " Ymax " YMax1
END
if (VaryParameter~=0)
THEN SAY "P - Parameter: ("ParameterStart") to ("ParameterEnd")"
SAY "D - Filename ("FileName")"
SAY "I - Instruction ("Instruction")"
SAY Overlay("L - Load Settings", "F - Frames ("Frames")",35)
SAY Overlay("S - Save Settings", "N - Next Frame ("NextFrame")",35)
SAY Overlay("W - Write Script", "G - Go!",35)
SAY "X - Exit"
OPTIONS PROMPT "--------------> "
PULL Command
RETURN command
/*================================== ZOOM ================================= */
Zoom:
IF (VaryCoords~=0) THEN
DO
XCenter0 = (XMin0+XMax0)/2
YCenter0 = (YMin0+YMax0)/2
XWidth0 = (XMax0-XMin0)
YWidth0 = (YMax0-YMin0)
XCenter1 = (XMin1+XMax1)/2
YCenter1 = (YMin1+YMax1)/2
XWidth1 = (XMax1-XMin1)
YWidth1 = (YMax1-YMin1)
xfactor = xwidth1/xwidth0
yfactor = ywidth1/ywidth0
END
IF (VaryParameter~=0) THEN
DO
ParameterWidth = ParameterEnd - ParameterStart
END
DO PictureNumber = NextFrame TO Frames-1 /* for each picture*/
Get DiskSpace MakeDiskName(Volume,DiskNumber) /* get disk with room */
DO WHILE (1*RESULT < 1*DiskMargin)
DiskNumber = DiskNumber+1
SAY "Please insert an empty diskette named "MakeDiskName(Volume,DiskNumber)
Get DiskSpace MakeDiskName(Volume,DiskNumber)
END
ok = Time('Reset')
fn.PictureNumber = MakeDiskName(Volume,DiskNumber)Path||Right(PictureNumber,4,"0")
SAY "Plotting: "fn.PictureNumber
mult = (PictureNumber) / (Frames-1) /* 0..1 */
IF (VaryParameter~=0) THEN
DO
Parameter = mult*ParameterWidth+ParameterStart
P Parameter
END
IF (VaryCoords~=0) THEN
DO
if (PictureNumber == 0) THEN /* avoid ARexx bug with -0 */
DO
XMin Xcenter0-XWidth0/2
XMax Xcenter0+XWidth0/2
YMin Ycenter0-YWidth0/2
YMax Ycenter0+YWidth0/2
END
ELSE
DO
xmag = power(xfactor,mult)
ymag = power(yfactor,mult)
xwidth = xwidth0*xmag
ywidth = ywidth0*ymag
xcenter = xcenter0+((xcenter1-xcenter0)*(xmag-1) / (xfactor-1) )
ycenter = ycenter0+((ycenter1-ycenter0)*(ymag-1) / (yfactor-1) )
Xmin xcenter-xwidth/2 /* plug in the new values */
Xmax xcenter+xwidth/2
Ymin ycenter-ywidth/2
Ymax ycenter+ywidth/2
END
END
Pathname fn.PictureNumber
if ( (Complete~=0) & (EXISTS(fn.PictureNumber)~=0) ) THEN
DO
OverPlot T
LoadPicture
'Complete' Complete
END
INTERPRET Instruction /* do the appropriate plot */
Get 'Complete'
Complete = RESULT
SAY D2c(11)"Saving: "
if ((PictureNumber==0) | (PictureNumber==Frames-1) )
THEN SavePictureAndFormula
ELSE SavePicture
if (Complete==0)
THEN NextFrame = PictureNumber+1
Get StopSign
IF Result = "T"
THEN BREAK
ElapsedTime = ElapsedTime + Time("Elapsed")
Say ConvertTime(ElapsedTime/(PictureNumber+1) * (Frames-1-PictureNumber))" to go."
END /* do */
StopSign "F"
return(0)
RETURN
/*---------------------------------- SaveSettings ------------------------- */
/* archive state of the animation program to disk */
SaveSettings:
ArchiveFile = GetAns("Save settings to", ArchiveFile)
IF (~OPEN(arch, ArchiveFile,'Write'))
THEN DO ok = SayError("Can't open file '"ArchiveFile"'"); Return(0); END
ok = WRITELN(Arch,"XMin0="Xmin0)
ok = WRITELN(Arch,"XMax0="Xmax0)
ok = WRITELN(Arch,"YMin0="Ymin0)
ok = WRITELN(Arch,"YMax0="Ymax0)
ok = WRITELN(Arch,"XMin1="Xmin1)
ok = WRITELN(Arch,"XMax1="Xmax1)
ok = WRITELN(Arch,"YMin1="Ymin1)
ok = WRITELN(Arch,"YMax1="Ymax1)
ok = WRITELN(Arch,"VaryCoords="VaryCoords )
ok = WRITELN(Arch,"VaryParameter="VaryParameter )
ok = WRITELN(Arch,"ParameterStart="ParameterStart )
ok = WRITELN(Arch,"ParameterEnd="ParameterEnd )
ok = WRITELN(Arch,"Frames="Frames )
ok = WRITELN(Arch,"DiskNumber="DiskNumber )
ok = WRITELN(Arch,"Volume='"Volume"'" )
ok = WRITELN(Arch,"Path='"Path"'" )
ok = WRITELN(Arch,"NextFrame="NextFrame )
ok = WRITELN(Arch,"Instruction='"Instruction"'" )
ok = WRITELN(Arch,"ElapsedTime="ElapsedTime )
ok = WRITELN(Arch,"Complete="Complete )
DO i = 0 to NextFrame-1
ok = WRITELN(Arch,"FN."i"='"fn.i"'")
END
ok = CLOSE(Arch)
RETURN(0)
END
/*---------------------------------- LoadSettings ------------------------- */
/* get archived state of the animation program from disk */
LoadSettings:
ArchiveFile = GetAns("Load settings from", ArchiveFile)
IF (~OPEN(arch, ArchiveFile,'Read'))
THEN DO ok = SayError("Can't open file '"ArchiveFile"'"); Return(0); END
DO WHILE ~EOF(Arch)
INTERPRET READLN(Arch) /* ARexx is SO SWEET! */
END
Filename = Volume":"Path
ok = CLOSE(Arch)
RETURN(0)
END
/*---------------------------------- WriteScript --------------------------- */
WriteScript:
ArchiveFile = GetAns("Save Script To", Volume":"Path"Script")
IF (~OPEN(arch, ArchiveFile,'Write'))
THEN DO ok = SayError("Can't open file '"ArchiveFile"'"); Return(0); END
DO i = 0 to NextFrame-1
ok = WRITELN(Arch,FN.i)
END
ok = CLOSE(Arch)
RETURN(0)
/* --------------------------------- GetAns -------------------------------- */
/* result = GetAns( prompt, default) */
/* prompt for input, displaying default. Accept one item. If only <return> */
/* was pressed, return the default answer */
GetAns: PROCEDURE
parse arg prompter, default
Options Prompt Prompter "(" Default "): "
parse pull response
if (response = "") THEN response = default;
return(response)
/*------------------------------- GetBoo ----------------------------------- */
/* result = GetBoo( prompt, default) */
/* prompt for boolean input, where 0 means false an <>0 means true */
/* parse the user input appropriately */
GetBoo: PROCEDURE
parse arg prompter, default
ans = GetAns( prompter, Boo2Text(default) )
if (ans==Boo2Text(default))
THEN return(default); /* pressed return! */
ans = left(ans,1,)
ret = 1
if(Index("0nN",ans)~=0)
THEN ret = 0;
return(ret)
/*----------------------------- Boo2Text ----------------------------------- */
/* result = Boo2Text( bnumber ) */
Boo2text:
parse arg bnumber
if (bnumber==0)
THEN return("No")
ELSE return("Yes")
/*------------------------------ MakeDiskName ------------------------------ */
MakeDiskName: PROCEDURE
parse arg volume, number
if (number==0)
THEN return(Volume)":"
ELSE return(volume||Number":")
/*------------------------------- SayError --------------------------------- */
/* display error message and wait for action */
SayError: PROCEDURE
parse arg prompter
say prompter
Options Prompt "Press <RETURN> to continue: "
pull response
return( 0 )
/*--------------------------------- Plural --------------------------------- */
/* make plural of words */
Plural: PROCEDURE
parse arg number
if (number~=1)
THEN return('s')
ELSE return('')
/*-------------------------------- ConvertTime ----------------------------- */
/* convert seconds to go into hours, days, min, etc */
ConvertTime: PROCEDURE
parse arg secs
Days = secs % (60*60*24)
secs = secs // (60*60*24)
Hours = secs % (60*60)
secs = secs // (60*60)
Mins = secs % (60)
secs = secs // (60)
secs = secs % (1)
if (Days ~=0) THEN return(Days" day"Plural(Days)" and "Hours" hour"Plural(Hours))
if (Hours~=0) THEN return(Hours" hour"Plural(Hours)" and "Mins" minute"Plural(Mins))
if (Mins ~=0) THEN return(Mins" minute"Plural(Mins)" and "Secs" second"Plural(Secs))
return(Secs" second"Plural(Secs))
POWER: /* number to power */
arg base, pow
Get Eval base"^"pow /* kick MathVision to evaluate this */
return(result)
ERROR: /* Error Diagnostic for return codes */
Get Diagnosis RC
SAY RESULT" on line "SIGL
DO i = 1 to 1000
END
EXIT